/*
 * @Author: C.
 * @Date: 2022-06-06 09:22:56
 * @LastEditTime: 2022-09-28 12:26:54
 * @Description: file content
 */

import {
  setDefaultTableSchema,
  setDefaultTableProps,
  setDefaultTreeEditTableProps,
} from "../utils/setDefaultProp";
import { treeEditTableDataInit } from "../utils/treeEditTableHelp";
class EditTreeTable {
  selectData = {
    keys: [],
    datas: [],
  };
  tableRef = null;
  tableData = [];
  props = {};
  constructor(props) {
    this.initProps(props);
  }
  initProps = (props) => {
    // this.initData(props)
    // 将props补充默认值
    const resultProps = setDefaultTreeEditTableProps(props);
    if (resultProps.tableSchema) {
      // 给tableSchema项补充默认值
      setDefaultTableSchema(resultProps.tableSchema);
    }
    Object.assign(this.props, resultProps, props);
  };
  // 填入数据
  setData = (data = []) => {
    if (!data || data.length == 0) return;
    this.tableData = treeEditTableDataInit(data);
  };
  concatData = (data = []) => {
    if (!data || data.length == 0) return;
    this.tableData = [...this.tableData, ...treeEditTableDataInit(data)];
  };
  // 初始化数据
  initData = (props) => {
    // this.tableData=treeEditTableDataInit(props.data)
  };
  getPropList = () => {
    return this.props.tableSchema.map((item) => {
      return item.prop;
    });
  };
}
export default EditTreeTable;
